package com.bw.cinema.adapter

import android.content.Context
import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
import com.bumptech.glide.Glide
import com.bw.cinema.databinding.ItemMutilVideoBinding
import com.bw.cinema.entity.MutilVideoEntity

class MutilVideoAdapter(val context: Context, val list: List<MutilVideoEntity>) :
    RecyclerView.Adapter<MutilVideoAdapter.MutilVideoViewHolder>() {
    class MutilVideoViewHolder(val binding: ItemMutilVideoBinding) :
        RecyclerView.ViewHolder(binding.root)

    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): MutilVideoViewHolder {
        val view = ItemMutilVideoBinding.inflate(LayoutInflater.from(context), parent, false)
        return MutilVideoViewHolder(view)
    }

    override fun onBindViewHolder(holder: MutilVideoViewHolder, position: Int) {
        val entity = list.get(position)

        Glide.with(context).load(entity.videomainimag).into(holder.binding.ivItemMutilVideoHeader)
        holder.binding.tvItemMutilVideoTitle.text = entity.title
        holder.binding.tvItemMutilVideoName.text = entity.name
    }

    override fun getItemCount(): Int {
        return list.size
    }
}